const getId = (ele)=>{
    const arr = window.location.search.slice(1).split("&")
    for (let i = 0;i < arr.length;i++){
        let item = arr[i].split("=")
        if (item[0] === ele){
            return item[1]
        }
    }
}
const singer = new Vue({
    el:".singer",
    data:{
       name:decodeURIComponent(getId("name")),
       songs:"",
       singerUrl:"",
       activeMusicId:"",
       seen:true,
       musicUrl:"",
    },
    created:
        function getList(){
            fetch(`http://localhost:3000/artist/songs?id=${getId("id")}`)
            .then(response => response.json())
            .then(data => {
                this.songs = data.songs
            }).finally(()=>{this.seen=false})
        },
    methods:{
        getSingerId(id,name){
            this.singerUrl = `./singer.html?id=${id}&name=${name}`
        },
        playAudio(id){
            this.musicUrl = `https://music.163.com/song/media/outer/url?id=${id}.mp3`
            this.activeMusicId = id
        }
    }
})